import storeRecoderModel2 from './model2/storeRecoderModel2';
import storeRecoderModel from './model/storeRecoderModel';
import visitMonthPlanModel from "./model/visitMonthPlanModel";
import visitMonthPlanModel2 from "./model2/visitMonthPlanModel2";
import consumerRecoderModel from "./model/consumerRecoderModel";
import consumerRecoderModel2 from "./model2/consumerRecoderModel2";
import emplModel from './model/empl2Model';

class Test2{
    constructor(){}

    async addData2(){
        let data=await storeRecoderModel.find({userid:'0651490869921242',month:'05'});
        let array:any[]=[]
        if(data.length>0){
            for (let index = 0; index < data.length; index++) {
                let a = data[index];
                // console.log(a,'a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_a_',index)
                array.push(a._id)
            }
        }
        console.log(array,'arrayarrayarrayarrayarrayarrayarrayarray',array.length)
        let data2=await visitMonthPlanModel.find({userId:'0651490869921242',month:'05',plantype:'门店'})
        console.log(data2.length,'data2_data2_data2_data2_data2_data2_data2_data2_',data2.length)
        if(data2.length>0){
            for (let index = 0; index < data2.length; index++) {
                let a2 = data2[index];
                // console.log(a2,'a2_a2_a2_a2_a2_a2_a2_a2_a2_',index)
                if(index>=15){
                   let b= await visitMonthPlanModel.update({_id:a2._id},{visitRecoder:array[index-15]})
                   console.log(b,'b_b_b_b_b_b_b_b_b_b_b_b_b_b_b_',index)
                }else{
                    let b= await visitMonthPlanModel.update({_id:a2._id},{visitRecoder:array[index]})
                    console.log(b,'b_b_b_b_b_b_b_b_b_b_b_b_b_b_b_',index)
                }
                
            }
        }
    }

    async addData(){
        let data=await storeRecoderModel2.find({})
        console.log(data.length,'????????????',data.length)
        if(data.length>0){
            for (let index = 0; index < data.length; index++) {
                 let res = data[index];
                let b=await storeRecoderModel.create({
                         sourceId: res.sourceId,
                         planId: res.planId,
                         timestamp: res.timestamp,
                         userid: res.userid,//员工的userid
                         month: res.month,
                         date: res.date,
                         planDate: res.planDate,
                         planType: res.planType,
                         storeName: res.storeName,
                         storeCode: res.storeCode,
                         storeType: res.storeType,//示范网吧  模范店等
                         position: res.position,
                         isChuchai: res.isChuchai,//是否出差
                         isListSample: res.isListSample,
                         sampleList: res.sampleList,
                         isListStandard: res.isListStandard,
                         competitor: res.competitor,
                         storeActivity: res.storeActivity,
                         pictureStoreActivity: res.pictureStoreActivity,
                         picture: res.picture,//门头照片
                         isListLetter: res.isListLetter,
                         listLetter: res.listLetter,
                         information: res.information
                                                      
                })
                console.log(b,'<<<<<<<<<<<<<<',index)
            }
         }    
         console.log('添加结束!!!!!!!!!')
    }

    async backupVisitConsumerRecoder2(){
        let data=await consumerRecoderModel2.find({})
        // let data2=await consumerRecoderModel2.find({})
        console.log(data.length,'????????????',data.length)
     
        if(data.length>0){
            for (let index = 0; index < data.length; index++) {
                let a = data[index];
                let b=await consumerRecoderModel.create({
                    sourceId: a.sourceId,
                    planId: a.planId,
                  
                    userid:a.userid,
                    jobnumber: a.jobnumber,
                    userName: a.userName,
                    
                    consumerName: a.consumerName,
                    consumerCode: a.consumerCode,
                    city: a.city,
                    cityType: a.cityType,
                    typeOne: a.typeOne,
                    typeTwo:a.typeTwo,
                    typeThree: a.typeThree,
                    typeFour: a.typeFour,
                    
                    typeFive: a.typeFive,
                    typeSix: a.typeSix,
                    typeSeven: a.typeSeven,
                    typeEight: a.typeEight,
                    typeNine: a.typeNine,
                    typeTen: a.typeTen,

                    comment:a.comment,

                    timestamp: a.timestamp,
                    month: a.month,
                    date:a.date,
                    planDate:a.planDate,
                    planType: a.planType,
                    consumerType: a.consumerType,
                    vistitWay: a.vistitWay,
                    position: a.position,
                    isChuchai: a.isChuchai,
                    picture: a.picture,
                    purpose:a.purpose,
                    talkingPerson:a.talkingPerson,
                    job: a.job,
                    connection: a.connection,
                    visitResult: a.visitResult,
                    followMatter: a.followMatter,
                    cooperation: a.cooperation 
                })
                console.log(b,'<<<<<<<<<<<<<<',index)
            }
        }  
        console.log('添加结束!!!!!!!!!')
    }

    async backupMonthPlan(){
        let data=await visitMonthPlanModel2.find({})
        console.log(data.length,'????????????',data.length)
        if(data.length>0){
            for (let index = 0; index < data.length; index++) {
                let element = data[index];
                let b=await visitMonthPlanModel.create({
                    sourceId: element.sourceId,
                    userId: element.userId,
                    user:element.user,
                    avatar:element.avatar,
                    jobnumber: element.jobnumber,
                    deptId: element.deptId,
                    provinceManager: element.provinceManager,
                    areaManager: element.areaManager,
                    modelManager: element.modelManager,      //模块负责人
                    nationalManager: element.nationalManager,//全国负责人
                    city: element.city,
                    roles: element.roles,     //角色
                    province: element.province,//员工所在省份
                    area: element.area,//员工所在区域
                    manageModel: element.manageModel,     //员工所在模块
                    team: element.team,//员工所在团队
                    nation:element.nation,
                    provinceName: element.provinceName,//省份名称
                    areaName: element.areaName,//区域名称
                    manageModelName: element.manageModelName,//模块名称
                    teamName:element.teamName,//团队名称
                    nationName: element.nationName,//全国名称
                    month: element.month,
                    visitRecoder: element.visitRecoder,
                    channel: element.channel,
                    mark: element.mark,
                    planDate: element.planDate,
                    consumerName: element.consumerName,
                    consumerCode: element.consumerCode,
                    rest: element.rest,
                    meeting: element.meeting,
                    plantype: element.plantype,
                    planStatus: element.planStatus,
                    customerType:element.customerType,
                    purpose: element.purpose,
                    comment: element.comment,
                    cancelApply: element.cancelApply,
                    remark: element.remark,
                    leadIndate:element.leadIndate
                })
                console.log(b._id,'<<<<<<<<<<<<<<',b.planDate,b.userId)
            }
        } 
        console.log('添加结束!!!!!!!!!')
        console.log(data.length,'????????????',data.length)
    }


}
let test2=new Test2();
export default test2;